﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Xml.Linq;
using System.Data;

namespace ZhangZhao.RenChangYou
{
    public partial class BaiDuMap : System.Web.UI.Page
    {
        private string Address
        {
            get
            {
                return Request.QueryString["address"];
            }
        }

        private string City
        {
            get
            {
                return Request.QueryString["city"];
            }
        }

        protected string Lat
        {
            get
            {
                return Request.QueryString["lat"];
            }
        }
        protected string Lng
        {
            get
            {
                return Request.QueryString["lng"];
            }
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            //string key = "9c4158f82a72555b121412650ff15b7e";

            //if (!string.IsNullOrEmpty(this.Address) && !string.IsNullOrEmpty(this.City))
            //{
            //    string url = string.Format("http://api.map.baidu.com/geocoder/v2/?ak={0}&callback=renderOption&output=xml&address={1}&city={2}", key, this.Address, this.City);

            //    HttpWebRequest httpWRequest = (HttpWebRequest)WebRequest.Create(url);
            //    using (HttpWebResponse httpWResponse = (HttpWebResponse)httpWRequest.GetResponse())
            //    {
            //        var result = XDocument.Load(httpWResponse.GetResponseStream());
            //        if (result != null)
            //        {
            //            foreach (var ele in result.Elements())
            //            {
            //                this.Lat = ele.Element("result").Element("location").Element("lat").Value.ToString();
            //                this.Lng = ele.Element("result").Element("location").Element("lng").Value.ToString();   
            //            }
            //        }
            //    }
            //}
        }
    }

}